<template>
    <el-row>
	  <el-col :span="4">
		   <el-input placeholder="请输入病历号搜索" v-model="query.caseNumber"/>
      </el-col>
	  <el-col :span="2">
	  		<el-button type="primary" plain @click="getPrescription">搜索</el-button>
	  </el-col>
    </el-row>
    <el-row>
        <el-col :span="8">姓名：{{register.realname}}</el-col>
        <el-col :span="8">身份证号：{{register.cardNumber}}</el-col>
        <el-col :span="8">住址：{{register.homeAddress}}</el-col>
    </el-row>
    
    <el-row>
         <el-col :span="24">
             <el-table :data="prescriptionList" >
                 <el-table-column label="药品名称" prop="drugInfo.drugName"></el-table-column>
                 <el-table-column label="药品规格" prop="drugInfo.drugFormat" />
                 <el-table-column label="用法用量" prop="drugUsage"></el-table-column>
                 <el-table-column label="数量" prop="drugNumber"/>
                 <el-table-column label="药品价格" prop="drugInfo.drugPrice" />
                 <el-table-column label="开立时间" prop="creationTime" />
                 <el-table-column label="状态" prop="drugState" />
                 <el-table-column label="操作" >
                    <template #default="{row}">
                        <el-button
                            size="small"
                            type="danger"
                            :disabled="row.drugState!='已缴费'"
                            @click="sendDrug(row)">发药
                        </el-button>
                    </template>
                </el-table-column>
             </el-table>
         </el-col>
     </el-row>
 </template>
 
 <script setup>
 import httpRequest from '@/common';
 import { ElMessage } from 'element-plus';
 import {ref,getCurrentInstance, onMounted,defineProps, watch, computed} from 'vue';
 
 const {proxy} = getCurrentInstance();
 
 const prescriptionList = ref([])
 
 const query = ref({
     caseNumber: ''
 })

 const register = ref({

 })
 
 const getRegister = ()=>{
    httpRequest(
        proxy,
        'post',
        '/register/case/'+query.caseNumber,
        null,
        resultBean=>{
            register.value = resultBean.data;
        }
    )
 }

 const getPrescription = ()=>{

    getRegister();

     httpRequest(
             proxy,
             'post',
             '/prescription/conditions',
             query.value,
             resultBean=>{
                 prescriptionList.value = resultBean.data;
             }
         )
 
 }
 
 onMounted(()=>{
     getPrescription();
 })
 
 </script>
 
 <style>
 </style>